package com.xmy.cultivate.mapper;

import com.xmy.cultivate.entity.RecordCourseCheck;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.HashMap;
import java.util.List;

/**
 * <p>
 * 课时核对 Mapper 接口
 * </p>
 *
 * @author hpiggy
 * @since 2024-06-04
 */
public interface RecordCourseCheckMapper extends BaseMapper<RecordCourseCheck> {

    @Select("SELECT IFNULL(SUM( residue_course_count ),0) AS residue_course_count,IFNULL(SUM( residue_price ),0) AS residue_price FROM order_detail WHERE deleted = 0 AND `status` <> 2 AND year_part = ${yearPart} AND quarter_num = ${quarterNum} AND student_id =${studentId} AND lesson_type = 1 AND subjects_id = ${subjectsId}")
    RecordCourseCheck getResidueCount (@Param("yearPart") Integer yearPart, @Param("quarterNum") Integer quarterNum, @Param("studentId") Long studentId, @Param("subjectsId") Long subjectsId);

    @Select("SELECT residue_course_count FROM record_course_check WHERE record_course_id = ${recordCourseId}")
    Integer getResidueCourseCount (@Param("recordCourseId") Long recordCourseId);

    @Select("select * from record_course_check where record_course_id = ${recordCourseId}")
    public RecordCourseCheck getOneForRecordCourseId(@Param("recordCourseId") Long recordCourseId);

}
